package com.jy.wms.service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.jy.wms.common.annotions.BaseServiceDescribe;
import com.jy.wms.common.base.BaseService;
import com.jy.wms.common.base.ServiceException;
import com.jy.wms.dao.WmsOwnerShipmentorderconfigMapper;
import com.jy.wms.pojo.WmsOwnerShipmentorderconfig;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @ClassName: WmsOwnerShipmentorderconfigService.java
* @Description: TODO(这里用一句话描述这个类的作用)
* @Author Jane
* @Date Fri Dec 29 17:07:20 CST 2017
*/

@Service
public class WmsOwnerShipmentorderconfigService extends BaseService<WmsOwnerShipmentorderconfigMapper,WmsOwnerShipmentorderconfig> {

 /**
 * 插入一条记录
 * @param entity 实体对象
 * @return int
 */
 @BaseServiceDescribe(moduleName = "新增发运订单导入配置信息",btnName = "新增发运订单导入配置信息")
public void baseInsert( WmsOwnerShipmentorderconfig entity)throws ServiceException {
     Integer f=dao.countBySsddqdId(entity.getSsddqdid());
     if(f==0){
         Integer count=dao.baseInsertSelective( entity );
         if(count<=0){
             throw new ServiceException("新增发运订单导入配置信息失败");
         }
     }else{
         throw new ServiceException("此订单渠道已有自定义字段不能新增，可修改");
     }

}

/**
* 插入一条记录（匹配有值的字段）
* @param entity 实体对象
* @return int
*/
public Integer baseInsertSelective(WmsOwnerShipmentorderconfig entity){
     return dao.baseInsertSelective( entity);
}

/**
* 删除（根据主键ID删除）
* @param id 主键
* @return int
*/
public Integer baseDeleteByPrimaryKey(String id){
     return dao.baseDeleteByPrimaryKey( id);
}

/**
* 删除（根据ID 批量删除）
* @param idList 主键ID列表
* @return int
*/
public Integer baseDeleteBathPrimaryKeys(List<String> idList){
     return dao.baseDeleteBathPrimaryKeys( idList );
}

/**
* 分页查询
* @param entity 实体
* @return Page<WmsOwnerShipmentorderconfig>
*/
public Page<WmsOwnerShipmentorderconfig> baseSelectPage(WmsOwnerShipmentorderconfig entity ){
    PageHelper.startPage(entity.getPage(),entity.getRows());
    return (Page<WmsOwnerShipmentorderconfig>)dao.baseSelectPage( entity );
}

/**
* 查询（根据主键ID查询）
* @param ssddpdid 所属订单渠道Id
* @return WmsOwnerShipmentorderconfig
*/
public WmsOwnerShipmentorderconfig baseSelectByPrimaryKey(String ssddpdid ){
     return dao.baseSelectByPrimaryKey( ssddpdid );
}

/**
* 查询（根据ID 批量查询）
* @param idList 主键ID列表
* @return list
*/
public Integer baseSelectBathPrimaryKeys(List<WmsOwnerShipmentorderconfig> idList ){
     return dao.baseSelectBathPrimaryKeys( idList );
}

/**
*修改 （匹配有值的字段）
* @param entity 主键ID列表
* @return int
*/
@BaseServiceDescribe(moduleName = "编辑发运订单导入配置信息",btnName = "编辑发运订单导入配置信息")
public void baseUpdateByPrimaryKeySelective( WmsOwnerShipmentorderconfig entity)throws ServiceException {
    Integer count=dao.baseUpdateByPrimaryKeySelective( entity);
    if(count<=0){
        throw new ServiceException("编辑发运订单导入配置信息失败");
    }
}

/**
*修改（根据主键ID修改）
* @param entity 主键ID列表
* @return int
*/
public Integer baseUpdateByPrimaryKey(WmsOwnerShipmentorderconfig entity){
     return dao.baseUpdateByPrimaryKey( entity);
}
}
